--[[---------------------------------------------------------

  Vortex Command



---------------------------------------------------------]]--

--Add clientside files
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )

--Serverside files
include( 'shared.lua' )

--Meta tables
local PlayerMeta = FindMetaTable("Player")

/*-----------------------------------
	Spawn
-----------------------------------*/
function GM:PlayerInitialSpawn( ply )
	 ply:Spectate(OBS_MODE_FIXED)
	 ply:SetPos(Vector(0,0,100))
	 
	 self:ShowTeam(ply)
end

function GM:PlayerSpawn( ply )
	 ply:SetupNewEntity()
end

function GM:PlayerLoadout( ply )
	 --I suggest physgun for now
	 ply:Give("weapon_physgun")
end

function GM:Think()
end

/*-----------------------------------
	Setup Entity
-----------------------------------*/

function PlayerMeta:SetupNewEntity()
	--spectate player
	self:Spectate(OBS_MODE_CHASE)
	self:SetCollisionGroup(COLLISION_GROUP_NONE)
	self:SetMoveType(MOVETYPE_NONE)
	
	--create entity
	local ent = ents.Create("player_ent")
	ent:SetPos(self:GetPos())
	ent:SetAngles(self:GetAngles())
	ent:Spawn()
	
	--set entity
	self.PlayerObject = ent
	self:AssignPlayerEntity(ent)
end

function PlayerMeta:AssignPlayerEntity(ent)
	 umsg.Start("vc_AssignPlayerEntity",self)
	 	umsg.Entity(ent) --hehe
	 umsg.End()
end

